﻿
@{
    ViewBag.Title = "Login";
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="~/Scripts/jquery-1.10.2.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/Site.css" rel="stylesheet" />
    <style type="text/css">
        .center {
            margin: 200px auto 0;
            width: 300px;
            height: 200px;
            text-align: center;
        }

        .field-validation-valid {
            color: red;
        }

        .msg {
            color: red;
            text-align: center;
        }
    </style>

</head>
<body>
    <div class="center">
        <form action="/Login/Login" method="post" onsubmit="return CheckFrom()">
            <div style="margin: 10px; ">帐号：<input type="text" id="txtLoginAccount" value="@ViewBag.LoginAccount" name="loginAccount" style="border:1px solid black;" /></div>
            <div style="margin: 10px; ">密码：<input type="password" id="txtLoginPwd" name="loginPwd" style="border:1px solid black;" /></div>
            <div><input type="submit" value="登录" class="btn btn-primary" /></div>
            <div class="msg">@ViewBag.Msg</div>
        </form>
    </div>
</body>
</html>
<script type="text/javascript">
    function CheckFrom() {
        var flag = true;
        var account = $("#txtLoginAccount").val();
        var pwd = $("#txtLoginPwd").val();
        if (account.trim().length == 0) {
            flag = false;
            $("#txtLoginAccount").css("border", "1px solid red");
        }
        else {
            $("#txtLoginAccount").css("border", "1px solid black");
        }
        if (pwd.trim().length == 0) {
            flag = false;
            $("#txtLoginPwd").css("border", "1px solid red");
        }
        else {
            $("#txtLoginPwd").css("border", "1px solid black");
        }
        if (!flag) {
            $("div.msg").text("");
        }
        return flag;
    }
</script>
